#pragma once

#include <iostream>
#include <unordered_map>

#include <functional>
using task_t = std::function<void()>;

void DownLoad()
{
    std::cout << "我是下载任务。。。" <<std::endl;
}
void log()
{
    std::cout << "我是日志任务。。。" <<std::endl;

}
void Sql()
{
    std::cout << "我是数据块同步任务。。。" <<std::endl;

}
static int number = 0;
class TaskManger
{
public:
    TaskManger()
    {
        srand(time(nullptr));
        InsertTask(DownLoad);
        InsertTask(log);
        InsertTask(Sql);

    }
    void InsertTask(task_t t)
    {
        tasks[number++] = t;
    }
    int SleltTask()
    {
        return rand() % number;
    }
    void Excute(int number)
    {
        if(tasks.find(number) == tasks.end()) return;
        tasks[number]();
    }
    ~TaskManger()
    {
    }

private:
    std::unordered_map<int, task_t> tasks;
    int num;
};
TaskManger tm;